import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/layout'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: "/dashboard"
  },
  {
    path: "/login",
    component: () => import('../views/Login')
  },
  {
    path: "/",
    component: Layout,
    children: [
      {
        path: "/userinfo",
        component: () => import('../views/UserInfo')
      },
      {
        path: "/dashboard",
        component: () => import('../views/Dashboard')
      },
      {
        path: "/member",
        component: () => import('../views/Member')
      },
      {
        path: "/project",
        component: () => import('../views/Project')
      },
      {
        path: "/system",
        component: () => import('../views/System')
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

// 解决跳转重复路由报错
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(to) {
  return VueRouterPush.call(this, to).catch(err => err)
}
export default router
